<?php

namespace App\Admin\Controllers\Api;

use App\Models\User;
use App\Http\Controllers\Controller;

class AreasController extends Controller
{
	public function province()
	{
		$areas = config('areas');

		$provinces = [];
		$i = 0;
		foreach ($areas as $k=>$v) {
			if($i>33){
				break;
			}
			$provinces[$i]['id'] = $k;
			$provinces[$i]['text'] = $v;
			$i++;

		}
		return $provinces;
	}

	public function area()
	{
		$areas = config('areas');

		$prefix = substr(request('q'), 0,2);
		
		$regions = [];
		$i = 0;
		foreach ($areas as $k=>$v) {
			if(substr($k, 0,2) == $prefix && request('q') != $k){
				$regions[$i]['id'] = $k;
				$regions[$i]['text'] = $v;
				$i++;
			}

		}
		return $regions;

	}


}
